#include <iostream>

#include "../../mqserver/virtual_host.hpp"
#include <gtest/gtest.h>

NS_Host::VirtualHost::Ptr host = std::make_shared<NS_Host::VirtualHost>("host", "./data", "./data/meta");

class VirtualHostTest : public testing::Environment
{
public:
    virtual void SetUp() override
    {
    }
    virtual void TearDown() override
    {
    }
};

// TEST(host_test, insert)
// {
//     host->declareExchange("exchange1", NS_Message::ExchangeType::DIRECT, true, true, "key1=val1&key2=val2");
//     ASSERT_EQ(host->exchangeSize(), 1);
//     host->declareMsgQueue("queue1", true, true, true, "key1=val1&key2=val2");
//     ASSERT_EQ(host->msgQueueSize(), 1);
//     host->declareBinding("exchange1", "queue1", "news.music.#");
//     host->declareBinding("exchange1", "queue2", "news.music.#");
//     ASSERT_EQ(host->bindingSize(), 1);
//     NS_Message::MessageProperties mp;
//     mp.set_id("apple");
//     mp.set_mode(NS_Message::DeliveryMode::DURABLE);
//     mp.set_routing_key("news.music.#");
//     host->basicPublish("queue1", &mp, "hello world");
//     ASSERT_EQ(host->queueMsgSize(), 1);
// }

// TEST(host_test, recovery)
// {
//     ASSERT_EQ(host->exchangeSize(), 1);
//     ASSERT_EQ(host->msgQueueSize(), 1);
//     ASSERT_EQ(host->bindingSize(), 1);
//     ASSERT_EQ(host->queueMsgSize(), 1);
// }

TEST(host_test, clear)
{
    host->clear();
    ASSERT_EQ(host->exchangeSize(), 0);
    ASSERT_EQ(host->msgQueueSize(), 0);
    ASSERT_EQ(host->bindingSize(), 0);
    ASSERT_EQ(host->queueMsgSize(), 0);
}



int main(int argc, char* argv[])
{
    testing::InitGoogleTest(&argc, argv);
    testing::AddGlobalTestEnvironment(new VirtualHostTest);
    
    return RUN_ALL_TESTS();
}